
//
//	This file tests reporting of E100X errors
//

//
// E1001: "this" is a keyword and cannot be assigned
//
doTest([
	'this = 3;'
], [
	[1001, 1, 1, 0]
]);

doTest([
	'this_ = 3;'
], [
	[2001, 1, 1, 0]	// this_ is undefined
]);


//
// E1002: Invalid destructuring to array
//
doTest([
	'var a;\n' +
	'[1] = [a];'
], [
	[1002, 2, 2, 0]
]);

doTest([
	'var a, b;\n' +
	'[a + 1] = [b];'
], [
	[1002, 2, 4, 0]
]);

doTest([
	'var a, b;\n' +
	'[a, b] = [b, a];'
], []);


//
// E1003: End tag does not match start tag in XML Element (when using E4X)
//
doTest([
	'<asdf></asd>;'
], [
	[1003, 1, 9, 0]
]);

doTest([
	'<asdf></asdf>;'
], []);


//
// E1004: Function declaration is missing the name of the function
//
doTest([
	'function(){};'
], [
	[1004, 1, 1, 0]
]);

doTest([
	'function f(){};'
], []);	// named

doTest([
	'var f = function(){};'
], []);	// inside expression

doTest([
	'(function(){});'
], []);	// inside expression

doTest([
	'(function() {\n' +
	'	function(){};' +
	'});'
], [
	[1004, 2, 2, 0]
]);


//
// E1005: Invalid RegExp flags (repeated or unknown)
//
doTest([
	'/bad/flags;'
], [
	[1005, 1, 6, 0]
]);

doTest([
	'/bad flags/igm;'
], []);


//
// E1006: Expression is not assignable
//
doTest([
	'var a, b;\n' +
	'a + b = 4;'
], [
	[1006, 2, 1, 0]
]);

doTest([
	'callMe() = 4;'
], [
	[1006, 1, 1, 0]
]);

doTest([
	'window.callMe() = 4;'
], [
	[1006, 1, 1, 0]
]);

doTest([
	'3 = 4;'
], [
	[1006, 1, 1, 0]
]);

doTest([
	'true = 4;'
], [
	[1006, 1, 1, 0]
]);

doTest([
	'"string" = 4;'
], [
	[1006, 1, 1, 0]
]);

doTest([
	'({ a : 2 } = 4);'
], [
	[1006, 1, 2, 0]
]);

doTest([
	'var a = 3 + 4;'
], []);

doTest([
	'window.a = 3;'
], []);


//
// E1007: The number of arguments for the getter or setter is incorrect.
//
doTest([
	'({ get asdf(newValue) { return null; } });'
], [
	[1007, 1, 8, 0]
]);

doTest([
	'({ set asdf() { return null; } });'
], [
	[1007, 1, 8, 0]
]);

doTest([
	'({ set asdf(newValue1, newValue2) { return null; } });'
], [
	[1007, 1, 8, 0]
]);

doTest([
	'({ get asdf() { return null; } });'
], []);

doTest([
	'({ set asdf(newValue) { return null; } });'
], []);


//
// E1008: The specified label does not exist, is not in the current context or cannot be used here.
//
doTest([
	'break asdf;'
], [
	[1008, 1, 7, 0]
]);

doTest([
	'asdf: while (1) {\n' +
	'	break asdf;' +
	'}'
], []);

doTest([
	'asdf: while (1) {\n' +
	'	break asdf1;' +
	'}'
], [
	[1008, 2, 8, 0]
]);

doTest([
	'asdf: function a() { while (1)\n' +
	'	break asdf;' +
	'}'
], [
	[1008, 2, 8, 0]
]);

doTest([
	'asdf: if (1) while (1)\n' +
	'	break asdf;'
], [
	[1008, 2, 8, 0]
]);

doTest([
	'sw: switch(a()) {\n' +
	'	case b: break sw;\n' +
	'	case c: d();\n' +
	'};'
], []);

doTest([
	'sw: switch(a()) {\n' +
	'	case b: continue sw;\n' +
	'	case c: d();\n' +
	'};'
], [
	[1008, 2, 19, 0]
]);

doTest([
	'switch(a()) {\n' +
	'	case b: continue;\n' +
	'	case c: d();\n' +
	'};'
], [
	[1008, 2, 10, 0]
]);

doTest([
	'while (0) switch(a()) {\n' +
	'	case b: continue;\n' +
	'	case c: d();\n' +
	'};'
], []);

//
// E1009
//
//
// E1010
//
//
// E1011
//


//
// E1012: Illegal variable name.
//
doTest([
	'var this;'
], [
	[1012, 1, 5, 0]
]);


//
// E1013: A semicolon was expected but not found.
//
doTest([
	'if (1) a() else {};'
], [
	[1013, 1, 12, 0]
]);

doTest([
	'do a while(0);'
], [
	[1013, 1, 6, 0]
]);

//
// E1014: An extra semicolon was encountered
//
doTest([
	'if (1) { call(); }; else {}'
], [
	[1014, 1, 19, 0]
]);

doTest([
	'do { call(); }; while(0);'
], [
	[1014, 1, 15, 0]
]);

//
// E1015: Invalid default directive
//
doTest([
	'default xml namespace = a;'
], []);

doTest([
	'default html namespace = a;'
], [
	[1015, 1, 9, 0]
]);

doTest([
	'default xml naamespace = a;'
], [
	[1015, 1, 13, 0]
]);
